package cn.iocoder.yudao.module.trade.scan.service;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.service.impl.BaseService;
import cn.iocoder.yudao.module.trade.scan.dal.dataobject.ScanOrderDO;
import cn.iocoder.yudao.module.trade.scan.dal.mysql.ScanOrderMapper;
import cn.iocoder.yudao.module.trade.scan.vo.AdminScanOrderQueryDTO;
import cn.iocoder.yudao.module.trade.scan.vo.AdminScanOrderVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

/**
 * 线下扫码订单 Service 实现类
 *
 * @author 山野羡民
 */
@Slf4j
@Service
@Validated
public class AdminScanOrderServiceImpl extends BaseService<ScanOrderDO, AdminScanOrderVO, AdminScanOrderQueryDTO> implements AdminScanOrderService {
    @Resource
    private ScanOrderMapper scanOrderMapper;

    @Override
    protected ScanOrderMapper getInjectedMapper() {
        return scanOrderMapper;
    }

    @Nonnull
    @Override
    protected CoreQueryWrapper<ScanOrderDO> buildQueryWrapper(AdminScanOrderQueryDTO param) {
        CoreQueryWrapper<ScanOrderDO> wrapper = super.buildQueryWrapper(param);
        wrapper.eqIfPresent("payed", param.getPayed());
        wrapper.eqIfPresent("trade_no", param.getTradeNo());
        wrapper.eqIfPresent("pay_no", param.getPayNo());
        wrapper.eqIfPresent("shop_id", param.getShopId());
        return wrapper;
    }

}